<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>观察和监听</title>
	</head>
	<body>
		<div id="app">
			<input type="text" name="" id="" value="" v-model="age" /><br>
			你的年龄是{{sum}}岁，{{msg}}
		</div>
		<script src="../js/Vue.js"></script>
		<script type="text/javascript">
			//创建 Vue 实例
			var app = new Vue({
				el: "#app",
				data: {
					name: 'jiangmin',
					age: 30,
					msg: '你好,你该找个工作了。'
				},
				computed: {
					sum() {
						return parseInt(this.age) + 20
					}
				},
				watch: {
					age() {
						alert('age 变化了！')
					}
				}
			})
		</script>

	</body>
</html>